< previous page page_601 next page >

Page 601
0601-01.jpg
Figure 17.11
Displaying a scene with hidden surface removal.
Other Objects
The geometry of a sphere is relatively simple. It is easy to transform a sphere using translations and rotations by transforming the sphere's center. As long as you know the sphere's radius and the transformed location of its center, you know where the sphere belongs. It is also easy to determine where a ray intersects a sphere, and it is easy to find the surface normal at any point on a sphere. For these reasons, spheres are extremely common in ray traced scenes.
Unfortunately, the whole world does not consist of spheres. If you want to use other kinds of objects in ray traced scenes, you must be able to write appropriate FindT and FindHitColor functions for them. If this proves too difficult for a particular object, you can approximate the object using polygons. While ray tracing will not give you smooth shading for objects approximated by polygons, you get all the other benefits of ray tracing such as hidden surface removal and shadows.
The following sections explain how to find ray-object intersections and surface normals for planes, disks, polygons, checkerboards, and cylinders.
Planes
Suppose you have a plane that passes through the point P = (px, py, pz) and that has normal vector N = <nx, ny, nz>. A point S = (x, y, z) lies on the plane if the vector between S and P is perpendicular to the normal vector N.
Recall that the value of the dot product of two vectors A and B is A B = |A| * |B| * Cos(q), where q is the angle between the two vectors. If the vector between points S and P is perpendicular to the normal vector N, Cos(q) = 0 between these two vectors, so the dot product must be zero. This gives one form of the equation of a plane:

 
< previous page page_601 next page >